package com.gec.system.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gec.model.system.ITripItinerary;
import com.gec.model.system.ITripItineraryOrder;
import com.gec.model.vo.ITripItineraryOrderVo;
import com.gec.system.common.Result;
import com.gec.system.service.ITripItineraryOrderService;
import com.gec.system.service.ITripItineraryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author dafei
 * @since 2024-01-23
 */
@Api(tags = "出行方式订单表")
@RestController
@RequestMapping("/system/itrItineraryOrder")
public class ITripItineraryOrderController {

    @Autowired
    private ITripItineraryOrderService itripItineraryOrderService;

    @Autowired
    private ITripItineraryService iTripItineraryService;

    // 分页 + 查询
    @ApiOperation("出行订单分页查询")
    @GetMapping("/{page}/{limit}")
    public Result findRoleByPageQuery(@PathVariable Long page,
                                      @PathVariable Long limit,
                                      ITripItineraryOrderVo iTripItineraryOrderVo) {
        IPage<ITripItineraryOrder> page1 = new Page<>(page, limit);
        page1 = this.itripItineraryOrderService.selectPage(page1, iTripItineraryOrderVo);
        return Result.ok(page1);
    }

//    @ApiOperation("添加出行订单")
//    @PostMapping("/addItineraryOrder")
//    public Result addItineraryOrder(@RequestBody ITripItineraryOrder iTripItineraryOrder){
//        this.itripItineraryOrderService.save(iTripItineraryOrder);
//        return Result.ok();
//    }

    @ApiOperation("根据id去查询出行订单")
    // 根据id去查询菜单
    @GetMapping("/findNodeById/{id}")
    public Result findNodeById(@PathVariable Long id) {
        ITripItineraryOrder iTripItineraryOrder = this.itripItineraryOrderService.getById(id);
        return Result.ok(iTripItineraryOrder);
    }



    @ApiOperation(value = "修改出行订单")
    @PostMapping("/updateITripItineraryOrder")
    public Result updateById(@RequestBody ITripItineraryOrder iTripServiceOrder) {
        itripItineraryOrderService.updateById(iTripServiceOrder);
        return Result.ok();
    }

    @ApiOperation(value = "删除出行订单")
    @DeleteMapping("/removeITripItineraryOrder/{id}")
    public Result removeITripItineraryOrder(@PathVariable Long id) {
        itripItineraryOrderService.removeById(id);
        return Result.ok();
    }

}

